package com.haotunet.app.goldtreasure.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.haotunet.app.goldtreasure.R;
import com.haotunet.app.goldtreasure.model.SellRecord;

import java.util.List;

public class SellRecordAdapter extends HolderAdapter<SellRecord, SellRecordAdapter.ViewHolder> {

	public SellRecordAdapter(Context context, List<SellRecord> mlist) {

		super(context, mlist);
	}

	public static class ViewHolder {
		TextView tvGoldQuantity;
		TextView tvCounterFee;
		TextView tvIncome;
		TextView tvGoldUnitPrice;
		TextView tvOrderNo;
		TextView tvSellTime;
		TextView sellType;
	}

	@Override
	public View buildConvertView(LayoutInflater layoutInflater, SellRecord t, int position) {
		return inflate(R.layout.item_sell_record);
	}

	@Override
	public ViewHolder buildHolder(View convertView, SellRecord t, int position) {
		ViewHolder holder = new ViewHolder();
		holder.tvGoldQuantity = (TextView) convertView.findViewById(R.id.gold_quantity);
		holder.tvGoldUnitPrice = (TextView) convertView.findViewById(R.id.gold_unit_price);
		holder.tvOrderNo = (TextView) convertView.findViewById(R.id.tv_sell_order_no);
		holder.sellType= (TextView) convertView.findViewById(R.id.sell_type);
		holder.tvIncome = (TextView) convertView.findViewById(R.id.txt_income);
		holder.tvSellTime = (TextView) convertView.findViewById(R.id.tv_sell_time);
		holder.tvCounterFee = (TextView) convertView.findViewById(R.id.counter_fee);
		return holder;
	}

	@Override
	public void bindViewDatas(View convertView, ViewHolder holder, SellRecord sellRecord, int position) {
		holder.tvGoldQuantity.setText(sellRecord.getQuantity());
		holder.tvGoldUnitPrice.setText(sellRecord.getPrice());
		holder.tvOrderNo.setText(sellRecord.getOrderNo());
		holder.sellType.setText(sellRecord.getSellType());
		holder.tvIncome.setText(sellRecord.getAmount());
		holder.tvSellTime.setText(sellRecord.getCreateTime());
		holder.tvCounterFee.setText(sellRecord.getCounterFee());
	}
}
